<?php
/**
 * @author kwor
 * @url http://www.kwor.cn
 *
 */
require_once 'glob.php';
require_once 'inc/lib/base/cls_gettheminfo.php';
$thems=new cls_thems();
$action=$_REQUEST['action'];
$page=$_REQUEST['page'];
if(!$action || $action=='baseedit')//默认显示
{
	//创建编辑器下拉选项列表
	$editorlist=get_dirname('inc/editor');
	$xueniao->assign('editorlist',$editorlist);

	//创建语言包下拉选项列表
	$langlist=get_dirname('lang');
	$xueniao->assign('langlist',$langlist);

	//初始化模块
	$xueniao->assign('modlist',get_modsarr('默认',0));

	$sql='select title,keywords,discretion,url,icp,editor,lang,logo,mods from sn_system';
	$systeminfo=$db->getrow($sql);

	//初始化上传文本框
	$uplogo=create_uploadfile('fm_logo','do/ajax/upimg.php',$systeminfo['logo']);
	$xueniao->assign('fm_logo',$uplogo);

	$xueniao->assign('systeminfo',$systeminfo);
	$xueniao->display('system_edit.htm');


}else if($action=='baseupdate')  //基本数据修改（需要完善）
{
	if($_REQUEST['fm_title']!==""){
		//修改更新数据
		$post=array(
		title=>$_REQUEST['fm_title'],
		keywords=>$_REQUEST['fm_keywords'],
		discretion=>$_REQUEST['fm_discretion'],
		url=>$_REQUEST['fm_url'],
		logo=>$_REQUEST['fm_logo'],
		icp=>$_REQUEST['fm_icp'],
		editor=>$_REQUEST['fm_editor'],
		mods=>$_REQUEST['fm_mods'],
		lang=>$_REQUEST['fm_lang']
		);

		$res=$db->update('sn_system',$post);
			
	}

	if($res==true)
	{
		sys_msg('站点信息修改成功！',0);
	}else
	{
		sys_msg('站点信息修改失败！',1);
	}
}else if($action=='contactedit')
{


	get_info('sn_system',array(qq,mail,tel,msn),'contactinfo','system_contacteedit.htm');

}else if($action=='contactupdate')  //基本数据修改（需要完善）
{
	if($_REQUEST['fm_tel']!==""){
		//修改更新数据
		$res=$db->update('sn_system',
		array(
		tel=>$_REQUEST['fm_tel'],
		qq=>$_REQUEST['fm_qq'],
		mail=>$_REQUEST['fm_mail'],
		msn=>$_REQUEST['fm_msn']
		));
	}


	if($res==true)
	{
		sys_msg('站点联系方式修改成功！',0);
	}else
	{
		sys_msg('站点联系方式修改失败！',1);
	}
}else if($action=='themselect')  //模板选择界面
{
	$themlist=$thems->get_them_dir('templates/');
	$res=$db->getrow('select skin from sn_system');
	$xueniao->assign('nowthem',$res['skin']);
	$xueniao->assign('themlist',$themlist);
	$xueniao->display('system_them_select.htm');

}else if ($action=='selectthem')//模板选择处理
{
	if($_REQUEST['themdir']!=="")
	{
		$res=$db->update('sn_system',
		array(
		skin=>$_REQUEST['themdir']
		)
		);
	}

	if($res==true)
	{
		$res=$db->getrow('select skin from sn_system');
		$xueniao->assign('nowthem',$res['skin']);

		$themlist=$thems->get_them_dir('templates/');
		$xueniao->assign('themlist',$themlist);
		$xueniao->display('system_them_select.htm');
	}else{
		sys_msg('模板选择失败！',0);
	}

}

?>